<?php
include "DBConnectMenu.php";

$id_menu	= "";
$strSQL		= "";
$pagina		= "";

$strSQL =	" SELECT id_menu_item, descricao, pagina " .
			" FROM menu_item WHERE id_menu = '". $_REQUEST['id_menu'] ."' ".
			" ORDER BY descricao ASC ";
$Menu = execute($strSQL);

if(isset($_REQUEST['pagina']) && !empty($_REQUEST['pagina'])){
	$pagina = $_REQUEST['pagina'];
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<HTML xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> 
	<HEAD>
		<LINK rel="stylesheet" type="text/css" href="css/padrao.css"/>
		<LINK rel="stylesheet" type="text/css" href="css/jquery-ui-1.8.10.custom.css"/>
		<SCRIPT language="javascript" type="text/javascript" src="js/jquery/jquery-1.4.4.min.js"></SCRIPT>
		<SCRIPT language="javascript" type="text/javascript" src="js/jquery/jquery-ui-1.8.10.custom.min.js"></SCRIPT>
		<STYLE type="text/css">
			*{
				padding: 0;
				margin: 0;
			}
			
			.menu{
				width: 100%;
				display: block;
				-webkit-border-top-left-radius: 50px;
				-webkit-border-bottom-left-radius: 50px;
				-moz-border-radius-topleft: 50px;
				-moz-border-radius-bottomleft: 50px;
				border-top-left-radius: 50px;
				border-bottom-left-radius: 50px;
			}
			
			.vazio{
				width: 10%;
				height: 30px;
			}
			
			.noborder{
				-webkit-border-radius: 0px;
				-moz-border-radius: 50px;
				border-radius: 0px;
				border: 1px solid #ffb73d;
				background: #ffc73d url(layout/images/ui-bg_glass_40_ffc73d_1x400.png) 50% 50% repeat-x;
				color: #111111;
				width: 100%;
				height: 30px;
				display: block;
				text-align: center;
			}
			
			.noborder:hover{
				cursor: pointer;
			}
			
			.back{
				width: 90%;
			}
			
			.principal{
				position: absolute;
				width:100%;
				height:100%;
			}
		</STYLE>
		<SCRIPT type="text/javascript">
			function menu(url){
				parent.content.location.href = "";
				parent.content.location.href = url;
			}
			
			$(function(){
				$(".menu").button();
			});
			
			function abre_grupo(op){
				if(op == 1){
					if(document.getElementById("grupo1").style.display != "inline"){
						document.getElementById("grupo1").style.display = "inline";
					}else{
						document.getElementById("grupo1").style.display = "none";
					}
				}
			}
			
			function clicar(){
				$('#menu_2').click();
				//document.getElementById('menu_2').click();
			}
		</SCRIPT>
	</HEAD>
	<BODY>
		<DIV class="principal ui-widget-header" align="right">
			<DIV class="vazio"></DIV>
			<?
			while ($linha = mysql_fetch_array($Menu)) {
				$id_menu = $id_menu .','. $linha['id_menu_item'];
			?>
			<DIV class="menu back" id="menu_<?echo $linha['id_menu_item']?>" style="border-right: 0px;"><?echo $linha['descricao']?></DIV>
			<?
			}
			
			mysql_data_seek($Menu,0);
			?>
			<INPUT type="hidden" name="id_menu_item" id="id_menu_item" value="<?echo $id_menu?>"/>
		</DIV>
	</BODY>
	<SCRIPT type="text/javascript" language="javascript">
		var _pag_selec = '<?echo $pagina?>';
		
		<?while($linha = mysql_fetch_array($Menu)){	?>
			$("#menu_<?echo $linha['id_menu_item']?>").click(function(){
				menu('<?echo $linha['pagina']?>');
				
				$("#menu_<?echo $linha['id_menu_item']?>").removeClass("back");
				$("#menu_<?echo $linha['id_menu_item']?>").addClass("ui-state-error");
				
				var _id_menu_item = document.getElementById("id_menu_item").value;
				_id_menu_item = _id_menu_item.split(',');
				
				for(var i=0;i<_id_menu_item.length;i++){
					if(_id_menu_item[i] != "" && _id_menu_item[i] != '<?echo Trim($linha['id_menu_item'])?>'){
						$("#menu_" + _id_menu_item[i]).addClass("back");
						$("#menu_" + _id_menu_item[i]).removeClass("ui-state-error");
					}
				}
			});
			
			if('<?echo $linha['pagina']?>' == _pag_selec){
				$("#menu_<?echo $linha['id_menu_item']?>").removeClass("back");
				$("#menu_<?echo $linha['id_menu_item']?>").addClass("ui-state-error");
				
				var _id_menu_item = document.getElementById("id_menu_item").value;
				_id_menu_item = _id_menu_item.split(',');
				
				for(var i=0;i<_id_menu_item.length;i++){
					if(_id_menu_item[i] != "" && _id_menu_item[i] != '<?echo Trim($linha['id_menu_item'])?>'){
						$("#menu_" + _id_menu_item[i]).addClass("back");
						$("#menu_" + _id_menu_item[i]).removeClass("ui-state-error");
					}
				}
			}
		<?
		}
		?>
	</SCRIPT>
</HTML>